<%--
  Created by IntelliJ IDEA.
  User: KoQia
  Date: 2021/12/18
  Time: 10:01
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<html>
<head>
    <title>Title</title>
</head>
<SCRIPT src="/js/jquery-3.4.1.min.js"></SCRIPT>
<style>
    tr, td, th {
        border: 1px solid red;
    }
</style>
<body>
<table style="border:1px solid red;width: 500px;height: 500px;border-collapse: collapse">
    <tr>
        <th>姓名</th>
        <th>密码</th>
    </tr>
    <c:forEach items="${byPage.list}" var="it">
        <tr>
            <td>${it.username}</td>
            <td>${it.password}</td>
        </tr>
    </c:forEach>
    <tr style="text-align: center">
        <c:if test="${byPage.isFirstPage}">
            <span>首页</span>
        </c:if>
        <c:if test="${byPage.hasPreviousPage}">
            <button id="first">首页</button>
        </c:if>
        <c:if test="${byPage.isFirstPage}">
            <span>上一页</span>
        </c:if>
        <c:if test="${byPage.hasPreviousPage}">
            <button id="upPage">上一页</button>
        </c:if>
        <c:if test="${byPage.isLastPage}">
            <span>下一页</span>
        </c:if>
        <c:if test="${byPage.hasNextPage}">
            <button  id="downPage">下一页</button>
        </c:if>
        <c:if test="${!byPage.isFirstPage}">
            <span>尾页</span>
        </c:if>
        <c:if test="${byPage.hasNextPage}">
            <button id="LastPage">尾页</button>
        </c:if>
    </tr>
</table>

<script>
    $(function (){
        $("#first").click(function (){
            window.location.href="${pageContext.request.contextPath}/findPage?page=1&size=3"
            })
        })
        $("#upPage").click(function (){
          window.location.href="${pageContext.request.contextPath}/findPage?page=${byPage.prePage}&size=3"
        })
        $("#downPage").click(function (){
                window.location.href="${pageContext.request.contextPath}/findPage?page=${byPage.nextPage}&size=3"
        })
        $("#LastPage").click(function (){
                window.location.href="${pageContext.request.contextPath}/findPage?page=${byPage.navigateLastPage}&size=3"
    })
</script>
</body>
</html>
